from django.db import connection as conn


class ConnDB(object):
    def __init__(self, sql):
        self._sql = sql
        self._cursor = conn.cursor()

    def set_sql(self, sql):
        self._sql = sql

    def get_sql(self):
        return self._sql

    def get_cursor(self):
        return self._cursor

    def action(self):
        self._cursor.execute(self._sql)
        return self._cursor.fetchall()

    def __del__(self):
        pass

